<!--
 *                   江城子 . 程序员之歌
 *
 *               十年生死两茫茫，写程序，到天亮。
 *                   千行代码，Bug何处藏。
 *               纵使上线又怎样，朝令改，夕断肠。
 *
 *               领导每天新想法，天天改，日日忙。
 *                   相顾无言，惟有泪千行。
 *               每晚灯火阑珊处，夜难寐，加班狂。
 *
 *
 * @Descripttion:
 * @version:
 * @Date: 2022-02-25 11:38:38
 * @LastEditors: huzhushan@126.com
 * @LastEditTime: 2022-04-05 16:41:33
 * @Author: huzhushan@126.com
 * @HomePage: https://huzhushan.gitee.io/vue3-element-admin
 * @Github: https://github.com/huzhushan/vue3-element-admin
 * @Donate: https://huzhushan.gitee.io/vue3-element-admin/donate/
 -->

<template>
  <el-card class="container" shadow="never">
    <div slot="header" class="header">
      <div class="title">
        消息收发概览
        <i class="el-icon-chat-dot-round icon"></i>
      </div>
    </div>
    <div v-loading="loading" class="content">
      <div class="item">
        <div class="title">今天</div>
        <div class="detail">
          <div class="receive">
            <p>收到</p>
            <i>{{ total.tdr }}</i>
          </div>
          <div class="send">
            <p>发出</p>
            <i>{{ total.tds }}</i>
          </div>
        </div>
      </div>
      <el-divider class="line" direction="vertical"></el-divider>
      <div class="item">
        <div class="title">昨天</div>
        <div class="detail">
          <div class="receive">
            <p>收到</p>
            <i>{{ total.ydr }}</i>
          </div>
          <div class="send">
            <p>发出</p>
            <i>{{ total.yds }}</i>
          </div>
        </div>
      </div>
      <el-divider class="line" direction="vertical"></el-divider>
      <div class="item">
        <div class="title">本周</div>
        <div class="detail">
          <div class="receive">
            <p>收到</p>
            <i>{{ total.ydrn }}</i>
          </div>
          <div class="send">
            <p>发出</p>
            <i>{{ total.ydsn }}</i>
          </div>
        </div>
      </div>
    </div>
    <div class="footer">
      <div class="item" @click="$router.push('/message/logs')">
        <i class="el-icon-time" />
        收发记录
      </div>
      <div class="item">
        <i class="el-icon-s-data" />
        消息统计
      </div>
    </div>
  </el-card>
</template>
<script>
import { GetTotal } from '@/api/home'
export default {
  data() {
    return {
      loading: false,
      total: {
        tdr: '',
        tds: '',
        ydrn: '',
        ydsn: '',
        ydr: '',
        yds: '',
      }
    }
  },
  async created() {
    this.loading = true
    const { code, data } = await GetTotal()
    this.loading = false
    if (+code === 1) {
      this.total = data || {}
    }
  }
}
</script>
<style lang="scss" scoped>
.content {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  .item {
    flex: 1;
    color: rgba(0, 0, 0, 0.45);
    text-align: center;
    .title {
      padding: 16px 0 32px;
      font-size: 16px;
    }
    .detail {
      display: flex;
      justify-content: space-around;
      font-size: 14px;
      p {
        margin: 0 0 12px;
      }
      i {
        font-size: 24px;
        color: rgba(0, 0, 0, 0.85);
        font-style: normal;
      }
    }
  }
  .line {
    height: auto;
    margin: 16px 0;
    background: rgba(0, 0, 0, 0.06);
  }
}
</style>
